package gui.swings;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

public class SwingFaces extends JPanel {
	static String str = "D:\\eclipse-jee-juno-SR1-win32\\workplace\\JavaSrc\\src\\gui\\swings\\face2.gif";
	static Icon[] faces = { new ImageIcon(str), new ImageIcon(str),
			new ImageIcon(str), new ImageIcon(str), new ImageIcon() };

	JButton jb = new JButton("JButton", faces[3]);
	JButton jb2 = new JButton("Disable");

	boolean mad = false;

	SwingFaces() {
		jb.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (mad == true) {
					jb.setIcon(faces[3]);
					mad = false;
				} else {
					jb.setIcon(faces[0]);
					mad = true;
				}
				jb.setVerticalAlignment(JButton.TOP);
				jb.setHorizontalAlignment(JButton.LEFT);

			}

		});

		jb.setRolloverEnabled(true);
		jb.setRolloverIcon(faces[1]);
		jb.setPressedIcon(faces[2]);
		jb.setDisabledIcon(faces[4]);
		jb.setToolTipText("Yow!");
		this.add(jb);
		jb2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (jb.isEnabled()) {
					jb.setEnabled(false);
					jb2.setText("Enable");
				} else {
					jb.setEnabled(true);
					jb2.setText("Disable");
				}
			}

		});
		this.add(jb2);
	}

	public static void main(String[] args) {
		SwingShow.inFrame(new SwingFaces(), 300, 300);
	}
}
